/** @format */

import Utils from 'taobao-mini-sdk/lib/utils'
import { UniBaseDao } from 'uni-base-dao'
import TBAPI from 'taobao-mini-sdk/lib/service/TBAPI'
import { createBaseDaoProxy, createTopApiProxy } from './utils/common/proxy'
// let MockConfig = require('../../mockServer/sdk')
const {
  DEFAULT_CODE_TYPES,
  dateFormatter: cloudDateFormatter,
  transformBeijingDate: cloudTransformBeijingDate,
  getStartTimestamp,
  getEndTimestamp,
  ResultsModel
} = Utils

const resultsModel = new ResultsModel()

let env = process.argv[2]
console.log(`env`, env)


// export const TBAPIS: typeof TBAPI = env === 'mock' ? MockConfig.TBAPIS : createTopApiProxy(TBAPI)
export const TBAPIS: any = createTopApiProxy(TBAPI)

// const BaseDao = env === 'mock' ? MockConfig.BaseDao : CloudBaseDao
const BaseDao = UniBaseDao

export function initBaseDao(context, dbName: string) {
  return createBaseDaoProxy(new BaseDao(context, dbName), context)
}

export const transformBeijingDate: typeof Utils.transformBeijingDate = cloudTransformBeijingDate

export const dateFormatter: typeof Utils.dateFormatter = cloudDateFormatter

export { DEFAULT_CODE_TYPES, resultsModel, getStartTimestamp, getEndTimestamp }
